﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WMSABL;
using WMSABL.SY;
using WMSAML.SY;
using ElectronicWMSA.Comm.ClassFiles;

namespace ElectronicWMSA.SY
{
    public partial class OnLineUsersFrm : Form
    {
        private string strWhereU = "";
        public OnLineUsersFrm()
        {
            InitializeComponent();
            this.strWhereU = " EnableStatus=1 AND  LoginStatus=1 ";
            this.pageControlU.PageCurrent = 1;
            this.pageControlU.PageSize = 20;
            this.pageControlU.Bind();
        }
        private int DBindU()
        {
            ElectronicWMSA.Comm.Forms.MsControls.PageData pageData = new ElectronicWMSA.Comm.Forms.MsControls.PageData();
            pageData.TableName = "Vlh_TUserRM";
            pageData.PrimaryKey = "User_id";
            pageData.OrderStr = "User_id";
            pageData.PageIndex = this.pageControlU.PageCurrent;
            pageData.PageSize = this.pageControlU.PageSize;
            pageData.QueryCondition = strWhereU;
            pageData.QueryFieldName = "*";
            this.pageControlU.bindingSource.DataSource = pageData.QueryDataTable().Tables[0];
            this.pageControlU.bindingNavigator.BindingSource = pageControlU.bindingSource;
            this.dataGridViewUserList.AutoGenerateColumns = false;
            this.dataGridViewUserList.DataSource = this.pageControlU.bindingSource;
            this.dataGridViewUserList.ClearSelection();
            return pageData.TotalCount;
        }
        private int pageControlU_EventPaging(ElectronicWMSA.Comm.Forms.MsControls.EventPagingArg e)
        {
            return DBindU();
        }
        private void dataGridViewUserList_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            SolidBrush b = new SolidBrush(dataGridViewUserList.RowHeadersDefaultCellStyle.ForeColor);
            e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), dataGridViewUserList.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
        }
        private void linkLabelClose_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Main._Main.CloseTabPages();
        }
        private void linkLabellinkLabelCloseAll_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Main._Main.CloseAllTabPages();
        }
        private void linkLabelCloseElse_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Main._Main.CloseTabPageElse();
        }
    }
}
